package com.ruoyi.paper.domain;

import java.time.Duration;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 实训试卷对象 exam_paper
 * 
 * @author ruoyi
 * @date 2025-04-14
 */
public class ExamPaper extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**  */
    private String paperId;

    /** 实训ID */
    @Excel(name = "实训ID")
    private String practiceId;

    /** 课程Id */
    @Excel(name = "课程Id")
    private String courseId;

    /** 试卷名称 */
    @Excel(name = "试卷名称")
    private String name;

    /** 考试开始时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "考试开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    /** 考试结束时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "考试结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /** 状态 */
    @Excel(name = "状态")
    private String status;

    /** 班级范围名称 */
    @Excel(name = "班级范围名称")
    private String roleClassName;

    /** 班级范围id */
    @Excel(name = "班级范围id")
    private String roleClassId;

    /** 试卷类别0:课程考试1：实训考试 */
    @Excel(name = "试卷类别0:课程考试1：实训考试")
    private String type;
    private String score;

    public String getScore() {
        return score;
    }

    public void setScore(String score) {
        this.score = score;
    }

    public long calculateDurationInMinutes() {
        if (this.startTime == null || this.endTime == null) {
            throw new IllegalArgumentException("开始时间和结束时间不能为空");
        }

        // 将Date对象转换为Instant对象
        java.time.Instant startInstant = this.startTime.toInstant();
        java.time.Instant endInstant = this.endTime.toInstant();

        // 计算两个Instant对象之间的Duration
        Duration duration = Duration.between(startInstant, endInstant);

        // 将Duration转换为分钟
        return duration.toMinutes();
    }

    public void setPaperId(String paperId) 
    {
        this.paperId = paperId;
    }

    public String getPaperId() 
    {
        return paperId;
    }

    public void setPracticeId(String practiceId) 
    {
        this.practiceId = practiceId;
    }

    public String getPracticeId() 
    {
        return practiceId;
    }

    public void setCourseId(String courseId) 
    {
        this.courseId = courseId;
    }

    public String getCourseId() 
    {
        return courseId;
    }

    public void setName(String name) 
    {
        this.name = name;
    }

    public String getName() 
    {
        return name;
    }

    public void setStartTime(Date startTime) 
    {
        this.startTime = startTime;
    }

    public Date getStartTime() 
    {
        return startTime;
    }

    public void setEndTime(Date endTime) 
    {
        this.endTime = endTime;
    }

    public Date getEndTime() 
    {
        return endTime;
    }

    public void setStatus(String status) 
    {
        this.status = status;
    }

    public String getStatus() 
    {
        return status;
    }

    public void setRoleClassName(String roleClassName) 
    {
        this.roleClassName = roleClassName;
    }

    public String getRoleClassName() 
    {
        return roleClassName;
    }

    public void setRoleClassId(String roleClassId) 
    {
        this.roleClassId = roleClassId;
    }

    public String getRoleClassId() 
    {
        return roleClassId;
    }

    public void setType(String type) 
    {
        this.type = type;
    }

    public String getType() 
    {
        return type;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("paperId", getPaperId())
            .append("practiceId", getPracticeId())
            .append("courseId", getCourseId())
            .append("name", getName())
            .append("startTime", getStartTime())
            .append("endTime", getEndTime())
            .append("status", getStatus())
            .append("roleClassName", getRoleClassName())
            .append("roleClassId", getRoleClassId())
            .append("type", getType())
            .toString();
    }
}
